package org.nepu.su.config;

import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Configuration
@EnableSwagger2WebMvc
@AllArgsConstructor
public class UnionKnife4jConfig {
    @Bean(value = "suApi")
    public Docket suApi() {
        String groupName="风险综合评价";
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("风险综合评价")
                .description("")
                .termsOfServiceUrl("http://localhost:8080")
                .version("1.0.0")
                .build();
        return new Docket(DocumentationType.SWAGGER_2)
                .host("http://localhost:8080/")
                .apiInfo(apiInfo)
                .groupName(groupName)
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.nepu.su"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean(value = "srrApi")
    public Docket srrApi() {
        String groupName="作业前风险评级";
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("作业前风险评级")
                .description("")
                .termsOfServiceUrl("http://localhost:8080")
                .version("1.0.0")
                .build();
        return new Docket(DocumentationType.SWAGGER_2)
                .host("http://localhost:8080/")
                .apiInfo(apiInfo)
                .groupName(groupName)
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.nepu.srr"))
                .paths(PathSelectors.any())
                .build();
    }


    @Bean(value = "scrApi")
    public Docket scrApi() {
        String groupName="符合性评级";
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("符合性评级")
                .description("")
                .termsOfServiceUrl("http://localhost:8080")
                .version("1.0.0")
                .build();
        return new Docket(DocumentationType.SWAGGER_2)
                .host("http://localhost:8080/")
                .apiInfo(apiInfo)
                .groupName(groupName)
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.nepu.scr"))
                .paths(PathSelectors.any())
                .build();
    }
}
